package mx.itesm.juego_proyecto;

import org.cocos2d.layers.CCScene;
import org.cocos2d.nodes.CCDirector;
import org.cocos2d.opengl.CCGLSurfaceView;
import org.cocos2d.sound.SoundEngine;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Nivel extends Activity {
    /** Called when the activity is first created. */
	private CCGLSurfaceView glSurfaceView;

	
	@Override
    public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        this.glSurfaceView = new CCGLSurfaceView(this);
        setContentView(this.glSurfaceView);
    	
    	Button btnnivel1;
    	Button btnnivel2;
    	
    	
    	
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nivel);
        
        
        
        btnnivel1=(Button) findViewById(R.id.btnnivel1);
        btnnivel2=(Button) findViewById(R.id.btnnivel2);
        
        btnnivel1.setOnClickListener(new OnClickListener() {
  	      public void onClick(View view) {
  	    	  Nivel1();
  	    	 
  	      	}
  	       });
        
        
        btnnivel2.setOnClickListener(new OnClickListener() {
  	      public void onClick(View view) {
  	    	  Nivel2();
  	    	 
  	      	}
  	       });
  
        
    }
	
	protected void onStart() {
    	super.onStart();
    	
    	CCDirector.sharedDirector().attachInView(glSurfaceView);
    	CCDirector.sharedDirector().setDisplayFPS(true);
    	CCDirector.sharedDirector().setAnimationInterval(1.0f/60.0f);
    	
    	CCScene escena = Juego.scene();
    	CCDirector.sharedDirector().runWithScene(escena);
    }
    
    protected void onPause() {
    	
    	super.onPause();
    	CCDirector.sharedDirector().pause();
    	SoundEngine.sharedEngine().pauseSound();
    	
    }
    
    protected void onResume() {
    	// TODO Auto-generated method stub
    	super.onResume();
    	CCDirector.sharedDirector().resume();
    	SoundEngine.sharedEngine().resumeSound();
    }
    
    @Override
    protected void onStop() {
    	super.onStop();
    	CCDirector.sharedDirector().end();
    }
    
   
    protected void onDestroy() {
    	super.onDestroy();
    	
    	SoundEngine.sharedEngine().realesAllEffects();
    	SoundEngine.sharedEngine().realesAllSounds();
    	SoundEngine.purgeSharedEngine();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    protected void Nivel1() {
    	/*onStart();
    	onPause();
    	onResume();
    	onStop();
    	onDestroy();*/
    	Intent nivel1 = new Intent(this, Juego.class);
		startActivity(nivel1);
		
    }
    protected void onStart1() { 
    super.onStart();
	
	CCDirector.sharedDirector().attachInView(glSurfaceView);
	CCDirector.sharedDirector().setDisplayFPS(true);
	CCDirector.sharedDirector().setAnimationInterval(1.0f/60.0f);
	
	CCScene escena = NivelDos.scene();
	CCDirector.sharedDirector().runWithScene(escena);
}
    
    
    private void Nivel2() {
    	/*onStart1();
    	onPause();
    	onResume();
    	onStop();
    	onDestroy();*/
    	Intent nivel2 = new Intent(this, NivelDos.class);
		startActivity(nivel2);
		
	}
    
}